<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>5 D | Glossary</title>
<meta name="author" content="psyTeachR Team">
<meta name="description" content='5.1 data frame A container data type for storing tabular data. data.frame(  id = 1:5,  name = c("Lisa", "Phil", "Helena", "Rachel", "Jack") )  id  name  1  Lisa  2  Phil  3  Helena  4  Rachel  5 ...'>
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta property="og:title" content="5 D | Glossary">
<meta property="og:type" content="book">
<meta property="og:url" content="https://psyteachr.github.io/glossary/d.html">
<meta property="og:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<meta property="og:description" content='5.1 data frame A container data type for storing tabular data. data.frame(  id = 1:5,  name = c("Lisa", "Phil", "Helena", "Rachel", "Jack") )  id  name  1  Lisa  2  Phil  3  Helena  4  Rachel  5 ...'>
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="5 D | Glossary">
<meta name="twitter:description" content='5.1 data frame A container data type for storing tabular data. data.frame(  id = 1:5,  name = c("Lisa", "Phil", "Helena", "Rachel", "Jack") )  id  name  1  Lisa  2  Phil  3  Helena  4  Rachel  5 ...'>
<meta name="twitter:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.11/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><script src="libs/bs3compat-0.3.1/transition.js"></script><script src="libs/bs3compat-0.3.1/tabs.js"></script><script src="libs/bs3compat-0.3.1/bs3compat.js"></script><link href="libs/bs4_book-1.0.0/bs4_book.css" rel="stylesheet">
<script src="libs/bs4_book-1.0.0/bs4_book.js"></script><script src="libs/kePrint-0.0.1/kePrint.js"></script><link href="libs/lightable-0.0.1/lightable.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-6NP3MF25W3"></script><script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-6NP3MF25W3');
    </script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- CSS --><link rel="stylesheet" href="include/psyteachr.css">
<link rel="stylesheet" href="include/webex.css">
<link rel="stylesheet" href="include/style.css">
</head>
<body data-spy="scroll" data-target="#toc">

<div class="container-fluid">
<div class="row">
  <header class="col-sm-12 col-lg-3 sidebar sidebar-book"><a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>

    <div class="d-flex align-items-start justify-content-between">
      <h1>
        <a href="index.html" title="">Glossary</a>
      </h1>
      <button class="btn btn-outline-primary d-lg-none ml-2 mt-1" type="button" data-toggle="collapse" data-target="#main-nav" aria-expanded="true" aria-controls="main-nav"><i class="fas fa-bars"></i><span class="sr-only">Show table of contents</span></button>
    </div>

    <div id="main-nav" class="collapse-lg">
      <form role="search">
        <input id="search" class="form-control" type="search" placeholder="Search" aria-label="Search">
</form>

      <nav aria-label="Table of contents"><h2>Table of contents</h2>
        <ul class="book-toc list-unstyled">
<li><a class="" href="index.html">Overview</a></li>
<li><a class="" href="symbols.html"><span class="header-section-number">1</span> Symbols</a></li>
<li><a class="" href="a.html"><span class="header-section-number">2</span> A</a></li>
<li><a class="" href="b.html"><span class="header-section-number">3</span> B</a></li>
<li><a class="" href="c.html"><span class="header-section-number">4</span> C</a></li>
<li><a class="active" href="d.html"><span class="header-section-number">5</span> D</a></li>
<li><a class="" href="e.html"><span class="header-section-number">6</span> E</a></li>
<li><a class="" href="f.html"><span class="header-section-number">7</span> F</a></li>
<li><a class="" href="g.html"><span class="header-section-number">8</span> G</a></li>
<li><a class="" href="h.html"><span class="header-section-number">9</span> H</a></li>
<li><a class="" href="i.html"><span class="header-section-number">10</span> I</a></li>
<li><a class="" href="j.html"><span class="header-section-number">11</span> J</a></li>
<li><a class="" href="k.html"><span class="header-section-number">12</span> K</a></li>
<li><a class="" href="l.html"><span class="header-section-number">13</span> L</a></li>
<li><a class="" href="m.html"><span class="header-section-number">14</span> M</a></li>
<li><a class="" href="n.html"><span class="header-section-number">15</span> N</a></li>
<li><a class="" href="o.html"><span class="header-section-number">16</span> O</a></li>
<li><a class="" href="p.html"><span class="header-section-number">17</span> P</a></li>
<li><a class="" href="q.html"><span class="header-section-number">18</span> Q</a></li>
<li><a class="" href="r.html"><span class="header-section-number">19</span> R</a></li>
<li><a class="" href="s.html"><span class="header-section-number">20</span> S</a></li>
<li><a class="" href="t.html"><span class="header-section-number">21</span> T</a></li>
<li><a class="" href="u.html"><span class="header-section-number">22</span> U</a></li>
<li><a class="" href="v.html"><span class="header-section-number">23</span> V</a></li>
<li><a class="" href="w.html"><span class="header-section-number">24</span> W</a></li>
<li><a class="" href="x.html"><span class="header-section-number">25</span> X</a></li>
<li><a class="" href="y.html"><span class="header-section-number">26</span> Y</a></li>
<li><a class="" href="z.html"><span class="header-section-number">27</span> Z</a></li>
</ul>

        <div class="book-extra">
          <p><a id="book-repo" href="https://github.com/psyteachr/glossary">View book source <i class="fab fa-github"></i></a></p>
        </div>
      </nav>
</div>
  </header><main class="col-sm-12 col-md-9 col-lg-7" id="content"><div id="d" class="section level1" number="5">
<h1>
<span class="header-section-number">5</span> D<a class="anchor" aria-label="anchor" href="#d"><i class="fas fa-link"></i></a>
</h1>

<div id="data-frame" class="section level2" number="5.1">
<h2>
<span class="header-section-number">5.1</span> data frame<a class="anchor" aria-label="anchor" href="#data-frame"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="c.html#container">container</a> data type for storing <a href="t.html#tabular-data">tabular data</a>.</dfn></p>
<div class="sourceCode" id="cb84"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">5</span>,
  name <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Lisa"</span>, <span class="st">"Phil"</span>, <span class="st">"Helena"</span>, <span class="st">"Rachel"</span>, <span class="st">"Jack"</span><span class="op">)</span>
<span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
name
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:left;">
Lisa
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:left;">
Phil
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:left;">
Helena
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:left;">
Rachel
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
Jack
</td>
</tr>
</tbody>
</table></div>
</div>

</div>
<div id="data-type" class="section level2" number="5.2">
<h2>
<span class="header-section-number">5.2</span> data type<a class="anchor" aria-label="anchor" href="#data-type"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The kind of data represented by an object.</dfn></p>
<ul>
<li>
<a href="i.html#integer">integer</a> (whole numbers like <code>1L</code>, <code>-10L</code>, <code>3000L</code>)</li>
<li>
<a href="d.html#double">double</a> (numbers like <code>-0.223</code>, <code>10.324</code>, <code>1e4</code>)</li>
<li>
<a href="c.html#character">character</a> (letters or words like "I love R")</li>
<li>
<a href="l.html#logical">logical</a> (<code>TRUE</code> or <code>FALSE</code>)</li>
<li>complex (numbers with real and imaginary parts like <code>2i</code>)</li>
</ul>
<p>Integers and doubles are both <a href="n.html#numeric">numeric</a>.</p>
<p>If you want to know what data type a variable is, use the function <code>typeof</code>.</p>
<div class="sourceCode" id="cb85"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/typeof.html">typeof</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span>
<span class="co">#&gt; [1] "double"</span></code></pre></div>
<div class="sourceCode" id="cb86"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/typeof.html">typeof</a></span><span class="op">(</span><span class="st">"10"</span><span class="op">)</span>
<span class="co">#&gt; [1] "character"</span></code></pre></div>
<div class="sourceCode" id="cb87"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/typeof.html">typeof</a></span><span class="op">(</span><span class="fl">10L</span><span class="op">)</span>
<span class="co">#&gt; [1] "integer"</span></code></pre></div>
<div class="sourceCode" id="cb88"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/typeof.html">typeof</a></span><span class="op">(</span><span class="fl">10</span> <span class="op">==</span> <span class="fl">10</span><span class="op">)</span>
<span class="co">#&gt; [1] "logical"</span></code></pre></div>
<div class="sourceCode" id="cb89"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/typeof.html">typeof</a></span><span class="op">(</span><span class="fl">10i</span><span class="op">)</span>
<span class="co">#&gt; [1] "complex"</span></code></pre></div>

</div>
<div id="data-wrangling" class="section level2" number="5.3">
<h2>
<span class="header-section-number">5.3</span> data wrangling<a class="anchor" aria-label="anchor" href="#data-wrangling"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The process of preparing data for visualisation and statistical analysis.</dfn></p>

</div>
<div id="default-value" class="section level2" number="5.4">
<h2>
<span class="header-section-number">5.4</span> default value<a class="anchor" aria-label="anchor" href="#default-value"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A value that a <a href="f.html#function">function</a> uses for an <a href="a.html#argument">argument</a> if it is skipped.</dfn></p>
<p>For example, <code><a href="https://rdrr.io/r/base/mean.html">mean()</a></code> has a default value of <code>FALSE</code> for the argument <code>na.rm</code> (don't ignore NA values).</p>
<div class="sourceCode" id="cb90"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">3</span>,<span class="cn">NA</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
<span class="co">#&gt; [1] NA</span></code></pre></div>
<p>So if you leave that argument out, it's the same as setting it to <code>FALSE</code>.</p>
<div class="sourceCode" id="cb91"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">x</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
<span class="co">#&gt; [1] NA</span></code></pre></div>
<p>And you have to explicitly set it if you want it to be different.</p>
<div class="sourceCode" id="cb92"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">x</span>, na.rm <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>
<span class="co">#&gt; [1] 2</span></code></pre></div>
<p>If an argument does not have a default value, you can't omit it. In the example below, there is no default value for <code>n</code>.</p>
<div class="sourceCode" id="cb93"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">x</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="op">)</span>
<span class="co">#&gt; Error in rnorm(): argument "n" is missing, with no default</span></code></pre></div>

</div>
<div id="degrees-of-freedom" class="section level2" number="5.5">
<h2>
<span class="header-section-number">5.5</span> degrees of freedom<a class="anchor" aria-label="anchor" href="#degrees-of-freedom"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The number of observations that are free to vary to produce a known outcome.</dfn></p>
<p>If you run 5 people and ask them their age, and you know the mean age of those 5 people is 20.1, then four of those people can have any age, but the 5th person must have a specific age to maintain the mean of 20.1. The mean age here is the known outcome and four people's age can vary freely, so the <em>degrees of freedom</em> is 4.</p>
<p>You need to know the degrees of freedom (usually abbreviated <em>df</em>) to interpret test statistics like t-values and F-values.</p>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:unnamed-chunk-128"></span>
<img src="_main_files/figure-html/unnamed-chunk-128-1.png" alt="How p-values vary depending on the degrees of freedom for specific t-values in a t-test." width="75%"><p class="caption">
Figure 5.1: How p-values vary depending on the degrees of freedom for specific t-values in a t-test.
</p>
</div>

</div>
<div id="dependent-variable" class="section level2" number="5.6">
<h2>
<span class="header-section-number">5.6</span> dependent variable<a class="anchor" aria-label="anchor" href="#dependent-variable"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The target variable that is being analyzed, whose value is assumed to depend on other variables.</dfn></p>
<p>You are generally interested in how other variables you have measured impact the dependent variable. For example, if you are testing the effect of stress on anxiety, stress would be your <a href="i.html#independent-variable">independent variable</a> and anxiety would be the dependent variable. The terms independent/dependent variable are typically used in an experimental context. In the context of regression, the dependent variable is often referred to as the <a href="r.html#response-variable">response variable</a>.</p>

</div>
<div id="descriptive" class="section level2" number="5.7">
<h2>
<span class="header-section-number">5.7</span> descriptive<a class="anchor" aria-label="anchor" href="#descriptive"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Statistics that describe an aspect of data (e.g., mean, median, mode, variance, range)</dfn></p>
<p>Contrast with <a href="i.html#inferential">inferential</a> statistics.</p>

</div>
<div id="deviation-score" class="section level2" number="5.8">
<h2>
<span class="header-section-number">5.8</span> deviation score<a class="anchor" aria-label="anchor" href="#deviation-score"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A score minus the mean</dfn></p>
<div class="sourceCode" id="cb94"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
  score <span class="op">=</span> <span class="fl">8</span><span class="op">:</span><span class="fl">12</span>
<span class="op">)</span> <span class="op">%&gt;%</span>
  <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>mean <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">score</span><span class="op">)</span>,
         deviation_score <span class="op">=</span> <span class="va">score</span> <span class="op">-</span> <span class="va">mean</span><span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
score
</th>
<th style="text-align:right;">
mean
</th>
<th style="text-align:right;">
deviation_score
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
8
</td>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
-2
</td>
</tr>
<tr>
<td style="text-align:right;">
9
</td>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
-1
</td>
</tr>
<tr>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
0
</td>
</tr>
<tr>
<td style="text-align:right;">
11
</td>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
12
</td>
<td style="text-align:right;">
10
</td>
<td style="text-align:right;">
2
</td>
</tr>
</tbody>
</table></div>
</div>

</div>
<div id="directory" class="section level2" number="5.9">
<h2>
<span class="header-section-number">5.9</span> directory<a class="anchor" aria-label="anchor" href="#directory"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A collection or "folder" of files on a computer.</dfn></p>
<p>In a file <a href="p.html#path">path</a>, each directory is separated by forward slashes, e.g., "dir1/dir2/file.Rmd".</p>
<p>Sometimes you need to check if a directory exists and/or make a new directory. For example, a script may save images in a directory called "images" that is in the same directory as the script (so you can use the <a href="r.html#relative-path">relative path</a>). Below is code for checking whether that directory exists and making it if it doesn't.</p>
<div class="sourceCode" id="cb95"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">path</span> <span class="op">&lt;-</span> <span class="st">"images"</span>

<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/files2.html">dir.exists</a></span><span class="op">(</span><span class="va">path</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span>
  <span class="fu"><a href="https://rdrr.io/r/base/files2.html">dir.create</a></span><span class="op">(</span><span class="va">path</span><span class="op">)</span>
<span class="op">}</span></code></pre></div>

</div>
<div id="discrete" class="section level2" number="5.10">
<h2>
<span class="header-section-number">5.10</span> discrete<a class="anchor" aria-label="anchor" href="#discrete"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Data that can only take certain values, such as integers.</dfn></p>
<p>Discrete data are not <a href="c.html#continuous">continuous</a>, so it doesn't make sense to have a value that is partway between two values. For example, the number of texts you send per day is discrete; you can't send 12.5 texts. Discrete data can be <a href="o.html#ordinal">ordinal</a> or <a href="n.html#nominal">nominal</a>.</p>

</div>
<div id="distribution" class="section level2" number="5.11">
<h2>
<span class="header-section-number">5.11</span> distribution<a class="anchor" aria-label="anchor" href="#distribution"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A way to describe the shape of data</dfn></p>
<ul>
<li><a href="n.html#normal-distribution">normal distribution</a></li>
<li><a href="b.html#binomial-distribution">binomial distribution</a></li>
<li><a href="p.html#poisson-distribution">Poisson distribution</a></li>
<li><a href="u.html#uniform-distribution">uniform distribution</a></li>
</ul>
</div>
<div id="double-brackets" class="section level2" number="5.12">
<h2>
<span class="header-section-number">5.12</span> double brackets<a class="anchor" aria-label="anchor" href="#double-brackets"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Two pairs of square brackets used to select a single item from a <a href="c.html#container">container</a> like a <a href="l.html#list">list</a>, <a href="d.html#data-frame">data frame</a>, or <a href="m.html#matrix">matrix</a> (e.g., data[[1]]).</dfn></p>
<div class="sourceCode" id="cb96"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">3</span>,
  x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1.4</span>, <span class="fl">2.3</span>, <span class="fl">8.2</span><span class="op">)</span>
<span class="op">)</span>

<span class="co"># double brackets return the id column as a vector</span>
<span class="va">data</span><span class="op">[[</span><span class="st">"id"</span><span class="op">]</span><span class="op">]</span> 
<span class="co">#&gt; [1] 1 2 3</span></code></pre></div>
<p>See <a href="b.html#brackets">brackets</a> for an explanation of the difference between <a href="s.html#single-brackets">single</a> and double brackets.</p>

</div>
<div id="double" class="section level2" number="5.13">
<h2>
<span class="header-section-number">5.13</span> double<a class="anchor" aria-label="anchor" href="#double"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="d.html#data-type">data type</a> representing a real decimal number</dfn>.</p>
<p>Examples of doubles are <code>1</code>, <code>1.0</code>, <code>-0.01</code>, or <code>1e4</code>.</p>

</div>
<div id="dynamic" class="section level2" number="5.14">
<h2>
<span class="header-section-number">5.14</span> dynamic<a class="anchor" aria-label="anchor" href="#dynamic"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Something that can change in response to user actions</dfn></p>
<p>For example, in a <a href="s.html#shiny">shiny</a> app, the following code creates dynamic and <a href="s.html#static">static</a> elements.</p>
<div class="sourceCode" id="cb97"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">dynamic</span> <span class="op">&lt;-</span> <span class="fu">shiny</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/shiny/man/textOutput.html">textOutput</a></span><span class="op">(</span><span class="st">"This text can change"</span><span class="op">)</span>
<span class="va">static</span> <span class="op">&lt;-</span> <span class="fu">shiny</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/htmltools/man/builder.html">p</a></span><span class="op">(</span><span class="st">"This text cannot change"</span><span class="op">)</span></code></pre></div>

</div>
</div>
<script>

/* update total correct if #webex-total_correct exists */
update_total_correct = function() {
  console.log("webex: update total_correct");

  if (t = document.getElementById("webex-total_correct")) {
    var correct = document.getElementsByClassName("webex-correct").length;
    var solvemes = document.getElementsByClassName("webex-solveme").length;
    var radiogroups = document.getElementsByClassName("webex-radiogroup").length;
    var selects = document.getElementsByClassName("webex-select").length;
    
    t.innerHTML = correct + " of " + (solvemes + radiogroups + selects) + " correct";
  }
}

/* webex-solution button toggling function */
b_func = function() {
  console.log("webex: toggle hide");
  
  var cl = this.parentElement.classList;
  if (cl.contains('open')) {
    cl.remove("open");
  } else {
    cl.add("open");
  }
}

/* function for checking solveme answers */
solveme_func = function(e) {
  console.log("webex: check solveme");

  var real_answers = JSON.parse(this.dataset.answer);
  var my_answer = this.value;
  var cl = this.classList;
  if (cl.contains("ignorecase")) {
    my_answer = my_answer.toLowerCase();
  }
  if (cl.contains("nospaces")) {
    my_answer = my_answer.replace(/ /g, "")
  }

  if (my_answer == "") {
    cl.remove("webex-correct");
    cl.remove("webex-incorrect");
  } else if (real_answers.includes(my_answer)) {
    cl.add("webex-correct");
    cl.remove("webex-incorrect");
  } else {
    cl.add("webex-incorrect");
    cl.remove("webex-correct");
  }

  // match numeric answers within a specified tolerance
  if(this.dataset.tol > 0){
    var tol = JSON.parse(this.dataset.tol);
    var matches = real_answers.map(x => Math.abs(x - my_answer) < tol)
    if (matches.reduce((a, b) => a + b, 0) > 0) {
      cl.add("webex-correct");
    } else {
      cl.remove("webex-correct");
    }
  }

  // added regex bit
  if (cl.contains("regex")){
    answer_regex = RegExp(real_answers.join("|"))
    if (answer_regex.test(my_answer)) {
      cl.add("webex-correct");
    }
  }

  update_total_correct();
}

/* function for checking select answers */
select_func = function(e) {
  console.log("webex: check select");
  
  var cl = this.classList
  
  /* add style */
  cl.remove("webex-incorrect");
  cl.remove("webex-correct");
  if (this.value == "answer") {
    cl.add("webex-correct");
  } else if (this.value != "blank") {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

/* function for checking radiogroups answers */
radiogroups_func = function(e) {
  console.log("webex: check radiogroups");

  var checked_button = document.querySelector('input[name=' + this.id + ']:checked');
  var cl = checked_button.parentElement.classList;
  var labels = checked_button.parentElement.parentElement.children;
  
  /* get rid of styles */
  for (i = 0; i < labels.length; i++) {
    labels[i].classList.remove("webex-incorrect");
    labels[i].classList.remove("webex-correct");
  }
  
  /* add style */
  if (checked_button.value == "answer") {
    cl.add("webex-correct");
  } else {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

window.onload = function() {
  console.log("onload");
  /* set up solution buttons */
  var buttons = document.getElementsByTagName("button");

  for (var i = 0; i < buttons.length; i++) {
    if (buttons[i].parentElement.classList.contains('webex-solution')) {
      buttons[i].onclick = b_func;
    }
  }

  /* set up webex-solveme inputs */
  var solveme = document.getElementsByClassName("webex-solveme");

  for (var i = 0; i < solveme.length; i++) {
    /* make sure input boxes don't auto-anything */
    solveme[i].setAttribute("autocomplete","off");
    solveme[i].setAttribute("autocorrect", "off");
    solveme[i].setAttribute("autocapitalize", "off");
    solveme[i].setAttribute("spellcheck", "false");
    solveme[i].value = "";

    /* adjust answer for ignorecase or nospaces */
    var cl = solveme[i].classList;
    var real_answer = solveme[i].dataset.answer;
    if (cl.contains("ignorecase")) {
      real_answer = real_answer.toLowerCase();
    }
    if (cl.contains("nospaces")) {
      real_answer = real_answer.replace(/ /g, "");
    }
    solveme[i].dataset.answer = real_answer;

    /* attach checking function */
    solveme[i].onkeyup = solveme_func;
    solveme[i].onchange = solveme_func;
  }
  
  /* set up radiogroups */
  var radiogroups = document.getElementsByClassName("webex-radiogroup");
  for (var i = 0; i < radiogroups.length; i++) {
    radiogroups[i].onchange = radiogroups_func;
  }
  
  /* set up selects */
  var selects = document.getElementsByClassName("webex-select");
  for (var i = 0; i < selects.length; i++) {
    selects[i].onchange = select_func;
  }

  update_total_correct();
}

</script><script>
$( document ).ready(function() {
  var cite = ' ';
  var psyteachr = ' <a href="https://psyteachr.github.io/"><img src="images/logos/psyteachr_logo.png" style="height: 31px; color: white;" alt="psyTeachR: Reproducible Research" /></a>';
  var license = ' <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/" target="blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"></a>';

  $("footer div.row div:eq(1) p").html(
    psyteachr + license + cite
  );
  
  $("#toc").appendTo($("#main-nav"));
});
</script><div class="chapter-nav">
<div class="prev"><a href="c.html"><span class="header-section-number">4</span> C</a></div>
<div class="next"><a href="e.html"><span class="header-section-number">6</span> E</a></div>
</div></main><div class="col-md-3 col-lg-2 d-none d-md-block sidebar sidebar-chapter">
    <nav id="toc" data-toggle="toc" aria-label="On this page"><h2>On this page</h2>
      <ul class="nav navbar-nav">
<li><a class="nav-link" href="#d"><span class="header-section-number">5</span> D</a></li>
<li><a class="nav-link" href="#data-frame"><span class="header-section-number">5.1</span> data frame</a></li>
<li><a class="nav-link" href="#data-type"><span class="header-section-number">5.2</span> data type</a></li>
<li><a class="nav-link" href="#data-wrangling"><span class="header-section-number">5.3</span> data wrangling</a></li>
<li><a class="nav-link" href="#default-value"><span class="header-section-number">5.4</span> default value</a></li>
<li><a class="nav-link" href="#degrees-of-freedom"><span class="header-section-number">5.5</span> degrees of freedom</a></li>
<li><a class="nav-link" href="#dependent-variable"><span class="header-section-number">5.6</span> dependent variable</a></li>
<li><a class="nav-link" href="#descriptive"><span class="header-section-number">5.7</span> descriptive</a></li>
<li><a class="nav-link" href="#deviation-score"><span class="header-section-number">5.8</span> deviation score</a></li>
<li><a class="nav-link" href="#directory"><span class="header-section-number">5.9</span> directory</a></li>
<li><a class="nav-link" href="#discrete"><span class="header-section-number">5.10</span> discrete</a></li>
<li><a class="nav-link" href="#distribution"><span class="header-section-number">5.11</span> distribution</a></li>
<li><a class="nav-link" href="#double-brackets"><span class="header-section-number">5.12</span> double brackets</a></li>
<li><a class="nav-link" href="#double"><span class="header-section-number">5.13</span> double</a></li>
<li><a class="nav-link" href="#dynamic"><span class="header-section-number">5.14</span> dynamic</a></li>
</ul>

      <div class="book-extra">
        <ul class="list-unstyled">
<li><a id="book-source" href="https://github.com/psyteachr/glossary/blob/master/terms/d.Rmd">View source <i class="fab fa-github"></i></a></li>
          <li><a id="book-edit" href="https://github.com/psyteachr/glossary/edit/master/terms/d.Rmd">Edit this page <i class="fab fa-github"></i></a></li>
        </ul>
</div>
    </nav>
</div>

</div>
</div> <!-- .container -->

<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

  <div class="col-12 col-md-6 mt-3">
    <p>"<strong>Glossary</strong>" was written by psyTeachR Team. It was last built on 2022-02-10.</p>
  </div>

  <div class="col-12 col-md-6 mt-3">
    <p>This book was built by the <a class="text-light" href="https://bookdown.org">bookdown</a> R package.</p>
  </div>

</div></div>
</footer><!-- dynamically load mathjax for compatibility with self-contained --><script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    var src = "true";
    if (src === "" || src === "true") src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML";
    if (location.protocol !== "file:")
      if (/^https?:/.test(src))
        src = src.replace(/^https?:/, '');
    script.src = src;
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script><script type="text/x-mathjax-config">const popovers = document.querySelectorAll('a.footnote-ref[data-toggle="popover"]');
for (let popover of popovers) {
  const div = document.createElement('div');
  div.setAttribute('style', 'position: absolute; top: 0, left:0; width:0, height:0, overflow: hidden; visibility: hidden;');
  div.innerHTML = popover.getAttribute('data-content');

  var has_math = div.querySelector("span.math");
  if (has_math) {
    document.body.appendChild(div);
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, div]);
    MathJax.Hub.Queue(function() {
      popover.setAttribute('data-content', div.innerHTML);
      document.body.removeChild(div);
    })
  }
}
</script>
</body>
</html>
